package com.itheima.stock.config;


import com.google.common.util.concurrent.RateLimiter;
import com.itheima.stock.properties.LimiterProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * RateLimiterConfiguration
 *
 * @author DanLi
 * @date 2025/7/14
 */
@Configuration
public class RateLimiterConfiguration {
    /**
     * 创建令牌桶限流器
     * @param limiterProperties
     * @return
     */
    @Bean
    public RateLimiter rateLimiter(LimiterProperties limiterProperties){
        return RateLimiter.create(limiterProperties.getMaxCount());
    }
}
